package com.md.value.html;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author 刘骄阳
 * 2024-05-15 23:40
 */
@Getter
@AllArgsConstructor
public enum LabelAttributeType {
  /**
   * 边框
   */
  BORDER(0, "border"),
  /**
   * 单元格间距
   */
  CELL_SPACING(1, "cellspacing"),
  /**
   * 行合并
   */
  ROWSPAN(2, "rowspan"),
  /**
   * 列合并
   */
  COLSPAN(3, "colspan"),

  /**
   * 宽
   */
  WIDTH(4, "width"),

  /**
   * 高
   */
  HEIGHT(5, "height"),

  /**
   * 图片的属性
   */
  SRC(6, "src");

  static final Map<String, LabelAttributeType> ENUM_MAP_STRING = Arrays.stream(LabelAttributeType.values())
    .collect(Collectors.toMap(LabelAttributeType::getAttributeName, e -> e));
  private final Integer code;
  private final String attributeName;

  public static LabelAttributeType of(final String styleName) {
    return ENUM_MAP_STRING.get(styleName);
  }
}
